using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Wootbar
{
    static class StringHelper
    {
        public static string InnerText(string strRawText, string strRegEx, string strEndRegEx)
        {
            try
            {
                // add escape chars
                strRegEx = strRegEx.Replace(")", @"\)");
                strRegEx = strRegEx.Replace("(", @"\(");
                strRegEx = strRegEx.Replace(".", @"\.");
                strRegEx = strRegEx.Replace("]", @"\]");
                strRegEx = strRegEx.Replace("[", @"\[");
                strRegEx = strRegEx.Replace("?", @"\?");

                string strPattern = "(.*?)";
                Match MatchObj = Regex.Match(strRawText, string.Concat(strRegEx,strPattern,strEndRegEx));

                if (MatchObj.Groups.Count > 1)                
                    return MatchObj.Groups[1].Value;             
                
                return "";
            }
            catch (Exception ex)
            {
                return (ex.Message);
            }
        }
    }
}
